/*Title of the article: "Choosing the risky option: Information and risk propensity in referendum campaigns"
Author: Davide Morisi, University of Vienna
Date: February 28, 2018

/// REPLICATION DO FILE -  BES DATA
This file replicates the findings from BES data included in the article and in the appendix


/// DATA: BRITISH ELECTION STUDY Wave 1-9 Internet Panel
Fieldhouse, Edward, Jane Green., Geoffrey Evans., Hermann Schmitt, Cees van der Eijk, Jonathan Mellon, and Christopher Prosser. 2016. British Election Study Internet Panel Waves 1-9.

Original data available at: http://www.britishelectionstudy.com/data-objects/panel-study-data/
Dataset: BES2015_W9_Panel_v1.2.dta*/

clear all
set more off
set maxvar 10000

*************
*RECODING

*Vote
recode scotReferendumVoteW3 (0=0 "No") (1=1 "Yes") (9999=.), gen(voteyesW3_yn)
label variable voteyesW3_yn "Vote in Scottish referendum (recalled)"
tab voteyesW3_yn
recode euRefVoteW9 (0=0 "Remain") (1=1 "Leave") (9999=.), gen(voteleaveW9_rl)
label variable voteleaveW9_rl "Vote in Brexit referendum (recalled)"
tab voteleaveW9_rl

*Risk propensity
*Scotland
gen riskTakingW1W2W3W4W501 = (riskTakingW1W2W3W4W5-1)/3
label variable riskTakingW1W2W3W4W501 "How willing are you to take risks?"
label de risk01 0"Very unwilling" 1"Very willing"
label values riskTakingW1W2W3W4W501 risk01
tab riskTakingW1W2W3W4W501
*Brexit
gen riskTakingW701 = (riskTakingW7-1)/3
label variable riskTakingW701 "How willing are you to take risks?"
label values riskTakingW701 risk01
tab riskTakingW701

*Education
recode profile_education_age (1=1 "15 or under") (2=2 "16") (3 4=3 "17-19") (5=4 "20+") (6=5 "Still studying") (7=.), gen(edu5)

*Income
xtile income5 = profile_gross_household if profile_gross_household<17, nq(5)
gen income6 = income5
replace income6 = 6 if profile_gross_household==17
label var income6 "Income quintiles + no reply"
label de income6 1"1st quin" 2"2nd quin" 3"3rd quin" 4"4th quin" 5"5th quin" 6"Prefer not to say"
label values income6 income6

*Left-right scale
gen lr_scaleW1W2W3W4W501 = lr_scaleW1W2W3W4W5/10
gen lr_scaleW7W8W901 = lr_scaleW7W8W9/10
label de lr 0"Left" 1"Right"
label values lr_scaleW1W2W3W4W501 lr
label values lr_scaleW7W8W901 lr

*Scottish identity
gen scottishnessW2r01 = (scottishnessW2-1)/6 if scottishnessW2!=9999
label variable scottishnessW2r01 "Scottish identity scale"
label de scottishnessW2r01 0"Not at all Scottish" 1"Very strongly Scottish"
label values scottishnessW2r01 scottishnessW2r01
*British identity
gen britishnessW8r01 = (britishnessW8-1)/6 if britishnessW8!=9999
label variable britishnessW8r01 "British identity scale"
label de britishnessW8r01 0"Not at all British" 1"Very strongly British"
label values britishnessW8r01 britishnessW8r01

*Party identification
recode partyIdW2 (10=0 "No, none") (1=1 "Con") (2=2 "Lab") (3=3 "Lib Dem") (4=4 "SNP") (6=6 "UKIP") (7=7 "Green") (8 9=9 "Other") (9999=.), gen(partyIdW2r2)
recode partyIdW8 (10=0 "No, none") (1=1 "Con") (2=2 "Lab") (3=3 "Lib Dem") (4=4 "SNP") (6=6 "UKIP") (7=7 "Green") (5 9=9 "Other") (9999=.), gen(partyIdW8r2)

*Trust in MPs
gen trustMPsW2r01=(trustMPsW2-1)/6 if trustMPsW2!=9999
gen trustMPsW7r01=(trustMPsW7-1)/6 if trustMPsW7!=9999
label variable trustMPsW2r01 "Trust MPs in general W2"
label de trust 0"No trust" 1"A great deal of trust"
label values trustMPsW2r01 trust
label variable trustMPsW7r01 "Trust MPs in general W7"
label values trustMPsW7r01 trust

*Perceived immigration
gen changeImmigW8r01 = (changeImmigW8-1)/4 if changeImmigW8!=9999
label variable changeImmigW8r01 "Immigration levels getting higher or lower"
label de changeImmigW8r01 0"Getting a lot lower" 1"Getting a lot higher"
label values changeImmigW8r01 changeImmigW8r01

*Newspaper reading
recode profile_newspaper (16=0 "No newspaper") (1/5 13/15=1 "Reading tabloid") (6/12=2 "Reading a broadsheet"), gen(newspaper)
label variable newspaper "Does R read any newspaper?"

*Time spent following politics in newspaper
recode infoSourcePaperW8 (1/2=1 "Low information") (3=2 "Mid information") (4/5=3 "High information") (9999=.), gen(info3)
label variable info3 "Information on politics"

*Weights for Scotland
egen totwt = sum(wt_core_W3), by(country)
ta totwt
egen totpop = count(wt_core_W3), by(country)
gen scaling = totpop /totwt
gen regwt_coreW3 = scaling * wt_core_W3
sum regwt_coreW3, d
drop scaling totwt totpop


********************
*ANALYSIS - Tables and figures in the paper

global demo_scot "gender Age i.edu5 i.income6"
global demo_brex "gender ageW8 i.edu5 i.income6"

*
*Table 1. Risk propensity and pro-change vote (BES Internet Panel)
*Scotland
logit voteyesW3_yn c.riskTakingW1W2W3W4W501 $demo_scot lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W501)
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.newspaper $demo_scot lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W501)
*Brexit
logit voteleaveW9_rl c.riskTakingW701 $demo_brex lr_scaleW7W8W901 [iweight=wt_core_W9]
margins, dydx(riskTakingW701)
logit voteleaveW9_rl c.riskTakingW701##i.info3 $demo_brex lr_scaleW7W8W901 [iweight=wt_core_W9]
margins, dydx(riskTakingW701)

*
*Figure 1. Effect of risk propensity on pro-change votes by information levels
*Scotland
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.newspaper $demo_scot lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins 0.newspaper 2.newspaper, dydx(riskTakingW1W2W3W4W501) post
coefplot, horiz xline(0) level(90) name(bes_scot1)
*Brexit
logit voteleaveW9_rl c.riskTakingW701##i.info3 $demo_brex lr_scaleW7W8W901 [iweight=wt_core_W9]
margins 1.info3 3.info3, dydx(riskTakingW701) post
coefplot, horiz xline(0) level(90) name(bes_brex1)
graph combine bes_scot1 bes_brex1


********************
*ANALYSIS - Tables and figures in the appendix

*
*Table A1. Risk propensity and pro-change vote (BES Internet Panel) - Additional logistic regressions
*Scotland
logit voteyesW3_yn riskTakingW1W2W3W4W501 $demo_scot lr_scaleW1W2W3W4W501 scottishnessW2r01 i.partyIdW2r2 trustMPsW2r01 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W501)
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.newspaper $demo_scot lr_scaleW1W2W3W4W501 scottishnessW2r01 i.partyIdW2r2 trustMPsW2r01 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W501)
*brexit
logit voteleaveW9_rl riskTakingW701 $demo_brex lr_scaleW7W8W901 britishnessW8r01 i.partyIdW8r2 trustMPsW7r01 changeImmigW8r01 [iweight=wt_core_W9]
margins, dydx(riskTakingW701)
logit voteleaveW9_rl c.riskTakingW701##i.info3 $demo_brex lr_scaleW7W8W901 britishnessW8r01 i.partyIdW8r2 trustMPsW7r01 changeImmigW8r01 [iweight=wt_core_W9]
margins, dydx(riskTakingW701)

*
*Table A2. Risk propensity, summary statistics
tab riskTakingW1W2W3W4W5 if country==2 & voteyesW3_yn!=. [iweight=regwt_coreW3]
tab riskTakingW7 if voteleaveW9_rl!=. [iweight=wt_core_W9]

*
*Table A3. Risk propensity (categorical) and pro-change vote (BES Internet Panel)
*scotland
logit voteyesW3_yn ib2.riskTakingW1W2W3W4W5 $demo_scot lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W5)
logit voteyesW3_yn ib2.riskTakingW1W2W3W4W5 $demo_scot lr_scaleW1W2W3W4W501 scottishnessW2r01 i.partyIdW2r2 trustMPsW2r01 if country==2 [iweight=regwt_coreW3]
margins, dydx(riskTakingW1W2W3W4W5)
*brexit
logit voteleaveW9_rl ib2.riskTakingW7 $demo_brex lr_scaleW7W8W901 [iweight=wt_core_W9]
margins, dydx(riskTakingW7)riskTakingW7
logit voteleaveW9_rl ib2.riskTakingW7 $demo_brex lr_scaleW7W8W901 britishnessW8r01 i.partyIdW8r2 trustMPsW7r01 changeImmigW8r01 [iweight=wt_core_W9]
margins, dydx(riskTakingW7)

*
*Table A4. Risk propensity and socio-economic status (BES Internet Panel)
*Recoding income
recode income5 (1/3=1 "mid/low income") (4/5=2 "high income"), gen(inc_dum)
*Panel A
*scotland
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.inc_dum gender Age i.edu5 lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.inc_dum##i.newspaper gender Age i.edu5 lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
*brexit
logit voteleaveW9_rl c.riskTakingW701##i.inc_dum gender ageW8 i.edu5 lr_scaleW7W8W901 [iweight=wt_core_W9]
logit voteleaveW9_rl c.riskTakingW701##i.inc_dum##i.info3 gender ageW8 i.edu5 lr_scaleW7W8W901 [iweight=wt_core_W9]
*Panel B - margins
*scotland
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.inc_dum gender Age i.edu5 lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins inc_dum, dydx(riskTakingW1W2W3W4W501)
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.inc_dum##i.newspaper gender Age i.edu5 lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins inc_dum, dydx(riskTakingW1W2W3W4W501) at(newspaper==0)
logit voteyesW3_yn c.riskTakingW1W2W3W4W501##i.inc_dum##i.newspaper gender Age i.edu5 lr_scaleW1W2W3W4W501 if country==2 [iweight=regwt_coreW3]
margins inc_dum, dydx(riskTakingW1W2W3W4W501) at(newspaper==2)
*brexit
logit voteleaveW9_rl c.riskTakingW701##i.inc_dum gender ageW8 i.edu5 lr_scaleW7W8W901 [iweight=wt_core_W9]
margins inc_dum, dydx(riskTakingW701)
logit voteleaveW9_rl c.riskTakingW701##i.inc_dum##i.info3 gender ageW8 i.edu5 lr_scaleW7W8W901 [iweight=wt_core_W9]
margins inc_dum, dydx(riskTakingW701) at(info3==1)
logit voteleaveW9_rl c.riskTakingW701##i.inc_dum##i.info3 gender ageW8 i.edu5 lr_scaleW7W8W901 [iweight=wt_core_W9]
margins inc_dum, dydx(riskTakingW701) at(info3==3)


